{% extends 'base.html' %}
{% block content %}
<h2>物联网卡池列表</h2>
<table class="table">
    <thead>
        <tr>
            <th>池名称</th>
            <th>所属用户</th>
            <th>总流量</th>
            <th>剩余流量</th>
            <th>备注</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
        {% for pool in page_obj %}
        <tr>
            <td>{{ pool.name }}</td>
            <td>{{ pool.owner.username }}</td>
            <td>{{ pool.total_flow }}</td>
            <td>{{ pool.remain_flow }}</td>
            <td>{{ pool.remark }}</td>
            <td><a href="/pool/{{ pool.id }}/" class="btn btn-info btn-sm">详情</a></td>
        </tr>
        {% endfor %}
    </tbody>
</table>
<!-- 分页控件 -->
<nav aria-label="Page navigation">
  <ul class="pagination">
    {% if page_obj.number > 1 %}
      <li class="page-item"><a class="page-link" href="?page=1">首页</a></li>
    {% endif %}
    {% if page_obj.has_previous %}
      <li class="page-item"><a class="page-link" href="?page={{ page_obj.previous_page_number }}">上一页</a></li>
    {% endif %}
    {% for num in page_obj.paginator.page_range %}
      {% if page_obj.number == num %}
        <li class="page-item active"><span class="page-link">{{ num }}</span></li>
      {% else %}
        <li class="page-item"><a class="page-link" href="?page={{ num }}">{{ num }}</a></li>
      {% endif %}
    {% endfor %}
    {% if page_obj.has_next %}
      <li class="page-item"><a class="page-link" href="?page={{ page_obj.next_page_number }}">下一页</a></li>
    {% endif %}
    {% if page_obj.number < page_obj.paginator.num_pages %}
      <li class="page-item"><a class="page-link" href="?page={{ page_obj.paginator.num_pages }}">尾页</a></li>
    {% endif %}
  </ul>
</nav>
{% endblock %}
